import 'package:flutter_kit_dsp/flutter_kit_dsp.dart';

import '../../tool/assets.dart';
import '../setting/my_setting.dart';

class MyHomeController extends HomeController {
  RxInt currentIndex = 0.obs;
  RxList<String> items = [assets.input, assets.level, assets.crossover, assets.eq, assets.delay, assets.setting].obs;
  RxList<String> items_select = [
    assets.input_select,
    assets.level_select,
    assets.crossover_select,
    assets.eq_select,
    assets.delay_select,
    assets.setting_select
  ].obs;
  late final RxList<BasePage> pages;
  late final Rx<MySetting> settings;
  late Rx<Widget> previousPage;
  Rx<Widget> get currentPage {
    if (currentIndex.value <= 4) {
      previousPage = pages[currentIndex.value].obs;
    }
    return currentIndex.value <= 4
        ? pages[currentIndex.value].obs
        : Stack(
            children: [Positioned.fill(child: previousPage.value), Positioned.fill(child: settings.value)],
          ).obs;
  }

  @override
  void onInit() {
    super.onInit();
    settings = MySetting().obs;
    pages = <BasePage>[
      AppPages.pages[1] as BasePage,
      AppPages.pages[4] as BasePage,
      AppPages.pages[2] as BasePage,
      AppPages.pages[3] as BasePage,
      AppPages.pages[5] as BasePage,
    ].obs;
  }
}
